Skip to content

fix(output): drain buffered records on TCP/UDP Stop (PIPE-1230) - #271

Open
Dylan-M wants to merge 1 commit into
dylanmyers/pipe-1231-count-tracker-racefrom
dylanmyers/pipe-1230-tcp-udp-stop-drain
Open

fix(output): drain buffered records on TCP/UDP Stop (PIPE-1230)#271
Dylan-M wants to merge 1 commit into
dylanmyers/pipe-1231-count-tracker-racefrom
dylanmyers/pipe-1230-tcp-udp-stop-drain

Conversation

@Dylan-M

@Dylan-M Dylan-M commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Proposed Change

The TCP and UDP outputs could drop buffered records on Stop(). Stop() closed the data channel and cancelled the worker context at the same time. The worker's select then chose at random between draining the channel and taking the cancelled context, so it often exited with records still buffered.

Stop() now stops the workers first, then drains whatever is still buffered before returning. With the workers gone the drain is the only reader, so delivery is deterministic. The drain is bounded by the write timeout, the stop timeout, and the caller's context. An unreachable destination can't hang shutdown.

How to validate
  • Automated: go test -race ./output/tcp/ ./output/udp/ passes. New tests cover the drain (records buffered at Stop all arrive), an unreachable destination (Stop returns without hanging), and the send-failure and context-cancelled paths. drainBuffered and drainTo are at 100% coverage.
  • Manual: point a TCP output at a listener, write a burst of records, call Stop, and confirm the listener receives all of them.
Checklist
  • Changes are tested
  • CI has passed

…ng them (PIPE-1230)

Assisted-by: Claude Opus 4.8
@Dylan-M
Dylan-M requested review from a team as code owners August 3, 2026 13:10

Dylan-M commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@Dylan-M Dylan-M changed the title fix(output): drain buffered records on TCP/UDP Stop instead of dropping them (PIPE-1230) fix(output): drain buffered records on TCP/UDP Stop (PIPE-1230) Aug 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant